package cn.xenosp.server.web.controller;

import cn.xenosp.server.common.Result;
import cn.xenosp.server.common.annotation.LogInfo;
import cn.xenosp.server.common.tools.ObjectConvert;
import cn.xenosp.server.module.loginLog.entity.LoginLogVO;
import cn.xenosp.server.module.loginLog.service.SysLoginLogService;
import cn.xenosp.server.module.operateLog.entity.SysOperateLogVO;
import cn.xenosp.server.module.operateLog.service.SysOperateLogService;
import cn.xenosp.server.module.role.entity.SysRoleVO;
import cn.xenosp.server.module.role.service.SysRoleService;
import cn.xenosp.server.module.roleMenu.entity.SysRoleMenu;
import cn.xenosp.server.module.roleMenu.service.SysRoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 项目名： service-web
 * 包路径： cn.xenosp.server.web.controller
 * 作者：   TongHui
 * 创建时间: 2024-12-12 09:47
 * 描述: TODO
 * 版本: 1.0
 */
@RestController
@RequestMapping("${app.config.api-base-url}/logs/")
public class LogsController {

    @Autowired
    SysLoginLogService sysLoginLogService;
    @Autowired
    SysOperateLogService sysOperateLogService;


    @LogInfo(operationModuleType = "日志模块",operationName = "分页查询",operationContent = "查询登录日志数据")
    @PostMapping("/login/getPage")
    public Result<?> getLoginPage(@RequestBody String body){
        try {
            LoginLogVO loginLogVO = ObjectConvert.urlStringToClass(body, LoginLogVO.class);
            return Result.OK("",sysLoginLogService.getPage(loginLogVO));
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("服务错误",null);
        }
    }

    @LogInfo(operationModuleType = "日志模块",operationName = "分页查询",operationContent = "查询操作日志数据")
    @PostMapping("/operate/getPage")
    public Result<?> getOperatePage(@RequestBody String body){
        try {
            SysOperateLogVO operateLogVO = ObjectConvert.urlStringToClass(body, SysOperateLogVO.class);
            return Result.OK("",sysOperateLogService.getPage(operateLogVO));
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("服务错误",null);
        }
    }
}
